.class Lcom/instagram/android/b/e;
.super Ljava/lang/Object;
.source "AnalyticsUploader.java"


# instance fields
.field private final a:Ljava/io/File;

.field private final b:Ljava/lang/String;

.field private final c:Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .parameter
    .parameter
    .parameter

    .prologue
    .line 30
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 31
    iput-object p2, p0, Lcom/instagram/android/b/e;->b:Ljava/lang/String;

    .line 32
    iput-object p3, p0, Lcom/instagram/android/b/e;->c:Ljava/lang/String;

    .line 33
    invoke-static {p1}, Lcom/instagram/android/b/f;->a(Landroid/content/Context;)Ljava/io/File;

    move-result-object v0

    iput-object v0, p0, Lcom/instagram/android/b/e;->a:Ljava/io/File;

    .line 34
    return-void
.end method

.method private a(Ljava/lang/String;)Lch/boye/httpclientandroidlib/HttpResponse;
    .locals 3
    .parameter

    .prologue
    .line 119
    new-instance v0, Lcom/instagram/android/b/w;

    iget-object v1, p0, Lcom/instagram/android/b/e;->b:Ljava/lang/String;

    iget-object v2, p0, Lcom/instagram/android/b/e;->c:Ljava/lang/String;

    invoke-direct {v0, p1, v1, v2}, Lcom/instagram/android/b/w;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 120
    invoke-static {}, Lcom/instagram/android/d/a/a;->a()Lcom/instagram/android/d/a/a;

    move-result-object v1

    invoke-virtual {v1, v0}, Lcom/instagram/android/d/a/a;->a(Lcom/instagram/android/d/c/g;)Lch/boye/httpclientandroidlib/HttpResponse;

    move-result-object v0

    return-object v0
.end method

.method private b(Ljava/io/File;)Lch/boye/httpclientandroidlib/HttpResponse;
    .locals 5
    .parameter

    .prologue
    .line 68
    const-string v0, "AnalyticsUploader"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Uploading file "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 70
    const/4 v1, 0x0

    .line 72
    :try_start_0
    invoke-direct {p0, p1}, Lcom/instagram/android/b/e;->c(Ljava/io/File;)Ljava/lang/String;

    move-result-object v0

    .line 73
    invoke-direct {p0, v0}, Lcom/instagram/android/b/e;->a(Ljava/lang/String;)Lch/boye/httpclientandroidlib/HttpResponse;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    .line 78
    :goto_0
    if-eqz v0, :cond_0

    invoke-interface {v0}, Lch/boye/httpclientandroidlib/HttpResponse;->getStatusLine()Lch/boye/httpclientandroidlib/StatusLine;

    move-result-object v1

    invoke-interface {v1}, Lch/boye/httpclientandroidlib/StatusLine;->getStatusCode()I

    move-result v1

    const/16 v2, 0xc8

    if-ne v1, v2, :cond_0

    .line 80
    invoke-virtual {p1}, Ljava/io/File;->delete()Z

    move-result v1

    .line 81
    if-nez v1, :cond_0

    .line 82
    const-string v1, "AnalyticsUploader"

    const-string v2, "File %s was not deleted"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-static {v2, v3}, Lcom/facebook/c/i/c;->a(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/facebook/e/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 88
    :cond_0
    if-eqz v0, :cond_1

    :try_start_1
    invoke-interface {v0}, Lch/boye/httpclientandroidlib/HttpResponse;->getEntity()Lch/boye/httpclientandroidlib/HttpEntity;

    move-result-object v1

    if-eqz v1, :cond_1

    .line 89
    invoke-interface {v0}, Lch/boye/httpclientandroidlib/HttpResponse;->getEntity()Lch/boye/httpclientandroidlib/HttpEntity;

    move-result-object v1

    invoke-static {v1}, Lch/boye/httpclientandroidlib/util/EntityUtils;->consume(Lch/boye/httpclientandroidlib/HttpEntity;)V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    .line 94
    :cond_1
    :goto_1
    return-object v0

    .line 74
    :catch_0
    move-exception v0

    .line 75
    const-string v2, "AnalyticsUploader"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Unable to read file "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3, v0}, Lcom/facebook/e/a/a;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    move-object v0, v1

    goto :goto_0

    .line 91
    :catch_1
    move-exception v1

    goto :goto_1
.end method

.method private c(Ljava/io/File;)Ljava/lang/String;
    .locals 5
    .parameter

    .prologue
    .line 98
    const/4 v2, 0x0

    .line 100
    :try_start_0
    new-instance v1, Ljava/io/InputStreamReader;

    new-instance v0, Ljava/io/FileInputStream;

    invoke-direct {v0, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    const-string v3, "UTF-8"

    invoke-direct {v1, v0, v3}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;Ljava/lang/String;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 101
    :try_start_1
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    .line 102
    const/16 v2, 0x400

    new-array v2, v2, [C

    .line 104
    :goto_0
    invoke-virtual {v1, v2}, Ljava/io/Reader;->read([C)I

    move-result v3

    const/4 v4, -0x1

    if-eq v3, v4, :cond_0

    .line 105
    const/4 v4, 0x0

    invoke-virtual {v0, v2, v4, v3}, Ljava/lang/StringBuilder;->append([CII)Ljava/lang/StringBuilder;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 109
    :catchall_0
    move-exception v0

    :goto_1
    invoke-static {v1}, Lcom/b/a/c/a;->a(Ljava/io/Closeable;)V

    throw v0

    .line 107
    :cond_0
    :try_start_2
    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    move-result-object v0

    .line 109
    invoke-static {v1}, Lcom/b/a/c/a;->a(Ljava/io/Closeable;)V

    return-object v0

    :catchall_1
    move-exception v0

    move-object v1, v2

    goto :goto_1
.end method


# virtual methods
.method public a()V
    .locals 4

    .prologue
    .line 42
    const-string v0, "AnalyticsUploader"

    const-string v1, "Attempting to upload analytics"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 44
    iget-object v0, p0, Lcom/instagram/android/b/e;->a:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/instagram/android/b/e;->a:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->isDirectory()Z

    move-result v0

    if-nez v0, :cond_2

    .line 45
    :cond_0
    const-string v0, "AnalyticsUploader"

    const-string v1, "No analytics directory exists, nothing to do"

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 56
    :cond_1
    return-void

    .line 49
    :cond_2
    iget-object v0, p0, Lcom/instagram/android/b/e;->a:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v1

    array-length v2, v1

    const/4 v0, 0x0

    :goto_0
    if-ge v0, v2, :cond_1

    aget-object v3, v1, v0

    .line 50
    invoke-direct {p0, v3}, Lcom/instagram/android/b/e;->b(Ljava/io/File;)Lch/boye/httpclientandroidlib/HttpResponse;

    move-result-object v3

    .line 51
    if-eqz v3, :cond_1

    .line 49
    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method public a(Ljava/io/File;)V
    .locals 0
    .parameter

    .prologue
    .line 59
    invoke-direct {p0, p1}, Lcom/instagram/android/b/e;->b(Ljava/io/File;)Lch/boye/httpclientandroidlib/HttpResponse;

    .line 60
    return-void
.end method
